//======knowledge页面的input 框
inputFn($('.totalWrap_knowledge .txtBox'));
//搜索框点击提交提交页面跳转
$('.totalWrap_knowledge .cent form').on('click','input[type="submit"]',function() {
	var $el=$('.totalWrap_knowledge form input[type="text"]');
	window.location.href="learn_knowledge.html"
	if($el.val() == $el.attr('data-txt')){
		window.location.href="javascript:void(0)";
	}else{
		window.location.href="learn_knowledge.html?keyword="+$el.val();
	}
})

    //    点击 收起>>  收起下拉详情显示部分;
$('.questionBtn_knowledge .inner .close').click(function() {
    $(this).closest('.activeLi').slideUp(function() {
        $(this).closest('.activeLi').siblings('.item').removeClass('dis');
    });
    $(".newswrap>.titlebar>.actext").removeClass('ac');
});
	//    右上角点击知识学习点击切换
$('.questionBtn_knowledge .right_text .sLeft').click(function() {
        $('.totalWrap_knowledge').addClass('on');
        $('.knowledgeBtn_knowledge').addClass('on')
        $('.questionBtn_knowledge').removeClass('on')
    })
    //    知识库点击切换
$('.knowledgeLayout .top .title').click(function() {
    $('.totalWrap_knowledge').removeClass('on');
    $('.knowledgeBtn_knowledge').removeClass('on');
    $('.questionBtn_knowledge').removeClass('on')
});
	//	数据传入
(function(){
	var CommonSucceed = AjaxComplete(2);
		//	最新知识
	RequestGTMC("listNewKnowledgeByNum", {
	        num : "5",
	        status : ""
	    },
	    function(data) {
	        console.log("最新知识 获取成功");
	        console.log(data);
			//	        存储id
	        var newKnowArray=[];
	        if (data.length !== 0) {
	        	
	            var str = "", $el = $("#knowIndex_bot_knowledge .newCont dl").last();
	            $el.empty();
	            str +='<dt>最新知识</dt>'
	            for (var i = 0; i < data.length; i++) {
	            	newKnowArray.push(data[i].id)
	                str += '<dd data-tit="'+data[i].title+'"><a><span class="tit">'+data[i].title+'</span><span class="time">'+ data[i].createDate +'</span></a></dd>';
	            }
	        }
	        $el.append(str);
	        AddDoneCount();
	        $('.totalWrap_knowledge .right_dl dd').click(function(){
	       		window.location.href="learn_knowledge.html?id="+newKnowArray[$(this).index()-1]+"&name="+$(this).attr('data-tit');
	        })
	    },
	    function() {
	        console.log("最新知识 调用失败");
	    },
	    function() {
	        console.log("最新知识 请求完成");
	    }
	);
		//	最热知识
	RequestGTMC("listHotKnowledgeByNum", {
	        num : "5",
	        status : ""
	    },
	    function(data) {
	        console.log("最热知识 获取成功");
	        console.log(data);
	        var hotKnowArray=[];
	        if (data.length !== 0) {
	            var str = "", $el = $("#knowIndex_bot_knowledge .newCont dl").first();
	            $el.empty();
	            str +='<dt>热门知识</dt>'
	            for (var i = 0; i < data.length; i++) {
	            	hotKnowArray.push(data[i].id)
	                str += '<dd data-tit="'+data[i].title+'"><a><span class="tit">'+data[i].title+'</span><span class="time">'+ data[i].create_date +'</span></a></dd>';
	            }
	        }
	        $el.append(str);
	        AddDoneCount();
	        $('.totalWrap_knowledge .left_dl dd').click(function(){
	       		window.location.href="learn_knowledge.html?id="+hotKnowArray[$(this).index()-1]+"&name="+$(this).attr('data-tit');
	        })
	    },
	    function() {
	        console.log("最热知识 调用失败");
	    },
	    function() {
	        console.log("最热知识 请求完成");
	    }
	);
})()




